package service.impl;

import dao.EmpDao;
import dao.impl.EmpDaoImpl;
import pojo.Emp;
import service.EmpService;

import java.sql.Timestamp;
import java.util.List;
import java.util.Scanner;

/**
 * 代码逻辑层的实现
 */
public class EmpServiceImpl implements EmpService{

    EmpDao ed=new EmpDaoImpl();

    /**
     * 查询所有员工信息
     */
    @Override
    public List<Emp> EmpList() {
        EmpDaoImpl ed=new EmpDaoImpl();
        List<Emp> list=ed.list();
        return list;
    }

    /**
     *分页查询员工信息
     * @return  list集合
     */
    @Override
    public List<Emp> pageList(int pageIndex, int pageNumber) {
        EmpDaoImpl ed=new EmpDaoImpl();
        List<Emp> list=ed.pageList(pageIndex,pageNumber);
        int count=ed.sumPage();
        count=count%pageNumber==0? count/pageNumber:count/pageNumber+1;
        System.out.println("总页数为:"+count);
        return list;
    }

    /**
     * 添加员工信息
     */
    @Override
    public int addEmp(Emp emp) {
        int bo=0;
        EmpDaoImpl ed=new EmpDaoImpl();
        bo=ed.addEmp(emp);
        return bo;
    }

    /**
     * 修改员工信息
     */
    @Override
    public int modifyEmp(Emp emp) {
        int bo=0;
        EmpDaoImpl ed=new EmpDaoImpl();
        bo=ed.modifyEmp(emp);
        return bo;
    }

    /**
     *删除员工信息
     */
    @Override
    public int deleteEmp(Emp emp) {
        int bo=0;
        EmpDaoImpl ed=new EmpDaoImpl();
        bo=ed.deleteEmp(emp);
        return bo;
    }

    /**
     * 查询员工是否存在
     */
    @Override
    public boolean queryIsExit(Emp emp) {
        boolean bo=false;
        EmpDaoImpl ed=new EmpDaoImpl();
        bo=ed.queryIsExit(emp);
        return bo;
    }

    @Override
    public Emp findEmp(int empno) {
        EmpDaoImpl ed=new EmpDaoImpl();
        return ed.findEmp(empno);
    }

    @Override
    public Emp login(String ename, int empno) {
        EmpDaoImpl ed=new EmpDaoImpl();
        return ed.login(ename,empno);
    }
  /*  @Test
    public void test(){
        Emp emp=findEmp(10019);
        System.out.println(emp);
    }*/

}
